//
//  SGInformationViewController.m
//  MomHelp
//
//  Created by xuguoyong on 16/8/11.
//  Copyright © 2016年 hudongkeji. All rights reserved.
//

#import "SGInformationViewController.h"
#import "SGInfomationHeaderViewCell.h"
#import "SGInfomationPhotoAndTextCell.h"
#import "SGInfomationVideoCell.h"
#import "SGTransmissionOfLove.h"

@interface SGInformationViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,weak) UITableView *tableView;

@end

@implementation SGInformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView = [self addTableViewWithDelegate:self style:UITableViewStyleGrouped];
    
    [self.tableView registerClass:[SGInfomationHeaderViewCell class] forCellReuseIdentifier:@"headCell"];
    
     [self.tableView registerClass:[SGInfomationPhotoAndTextCell class] forCellReuseIdentifier:@"photoAndTextCell"];
    [self.tableView registerClass:[SGInfomationVideoCell class] forCellReuseIdentifier:@"videoCell"];
  
    [self.tableView addRefrshGifHeaderWithRefreshBlock:^{
        
    } andRefrshGifAutoFooterWithRefreshBlock:^{
        
    }];
    
    [SGDataServer ]
    
    
}

#pragma mark --请求资讯数据
- (void)requestInfomationData
{
    
}


#pragma mark  - UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    }
    return 20;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        SGInfomationHeaderViewCell *headCell = [tableView dequeueReusableCellWithIdentifier:@"headCell"];
        return headCell;
    }
    
    if (indexPath.row %3 ==0 && indexPath.row != 0) {
       
        SGInfomationVideoCell *videoCell =[tableView dequeueReusableCellWithIdentifier:@"videoCell"];
        return videoCell;
        
    }
    SGInfomationPhotoAndTextCell *photoAndTextCell = [tableView dequeueReusableCellWithIdentifier:@"photoAndTextCell"];
    return photoAndTextCell;

    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return d_screen_width *(300/750.0f)/*图片比例*/;
    }
    
    if (indexPath.row %3 == 0 && indexPath.row != 0)  {
        return (d_screen_width - 30)*((424.0f/690.0f))+90;//302.5f;//
        
    }
    
    return 130.0f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 0.0000001;
    }
    return 10.0f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (section == 0) {
        return 0.0001;
    }
    return 0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    SGTransmissionOfLove *love = [[SGTransmissionOfLove alloc] init];
    [self.navigationController pushViewController:love animated:YES];
}

@end
